package com.u1zz.zeus.module.iot.dal.mysql.productcategory;

import java.util.*;

import com.u1zz.zeus.framework.common.pojo.PageResult;
import com.u1zz.zeus.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.u1zz.zeus.framework.mybatis.core.mapper.BaseMapperX;
import com.u1zz.zeus.module.iot.dal.dataobject.productcategory.ProductCategoryDO;
import org.apache.ibatis.annotations.Mapper;
import com.u1zz.zeus.module.iot.controller.admin.productcategory.vo.*;

/**
 * 产品分类 Mapper
 *
 * @author u1zz
 */
@Mapper
public interface ProductCategoryMapper extends BaseMapperX<ProductCategoryDO> {

    default List<ProductCategoryDO> selectList(ProductCategoryListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ProductCategoryDO>()
                .eqIfPresent(ProductCategoryDO::getParentId, reqVO.getParentId())
                .eqIfPresent(ProductCategoryDO::getCategoryKey, reqVO.getCategoryKey())
                .likeIfPresent(ProductCategoryDO::getCategoryName, reqVO.getCategoryName())
                .eqIfPresent(ProductCategoryDO::getDescription, reqVO.getDescription())
                .betweenIfPresent(ProductCategoryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProductCategoryDO::getId));
    }

	default ProductCategoryDO selectByParentIdAndCategoryName(Long parentId, String categoryName) {
	    return selectOne(ProductCategoryDO::getParentId, parentId, ProductCategoryDO::getCategoryName, categoryName);
	}

    default Long selectCountByParentId(Long parentId) {
        return selectCount(ProductCategoryDO::getParentId, parentId);
    }

}